package com.xunwulian.web.bean;

import com.xunwulian.base.util.BeanUtil3;
import com.xunwulian.base.util.HttpUtil;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/3/21.
 */
public class ZfbCallback implements Serializable {
    public static final String TRADE_STATUS_WAIT = "WAIT_BUYER_PAY";
    public static final String TRADE_STATUS_SUCCESS = "TRADE_SUCCESSS";

    public List<FundBill> fund_bill_list;
    public String subject;
    public String trade_no;
    public String gmt_create;
    public String notify_type;
    public Double total_amount;
    public String out_trade_no;
    public Double invoice_amount;
    public String open_id;
    public String seller_id;
    public String notify_time;
    public String trade_status;
    public String gmt_payment;
    public String seller_email;
    public Double receipt_amount;
    public String buyer_id;
    public String app_id;
    public String notify_id;
    public String buyer_logon_id;
    public String sign_type;
    public Double buyer_pay_amount;
    public String sign;
    public Double point_amount;

    public ZfbCallback(Map<String, String> params) {
        subject = params.get("subject");
        trade_no = params.get("trade_no");
        gmt_create = params.get("gmt_create");
        notify_type = params.get("notify_type");
        try {
            total_amount = Double.parseDouble(params.get("total_amount"));
        } catch (Exception e) {
        }
        out_trade_no = params.get("out_trade_no");
        try {
            invoice_amount = Double.parseDouble(params.get("invoice_amount"));
        } catch (Exception e) {
        }
        open_id = params.get("open_id");
        seller_id = params.get("seller_id");
        notify_time = params.get("notify_time");
        trade_status = params.get("trade_status");
        gmt_payment = params.get("gmt_payment");
        seller_email = params.get("seller_email");
        try {
            receipt_amount = Double.parseDouble(params.get("receipt_amount"));
        } catch (Exception e) {
        }
        buyer_id = params.get("buyer_id");
        app_id = params.get("app_id");
        notify_id = params.get("notify_id");
        buyer_logon_id = params.get("buyer_logon_id");
        sign_type = params.get("sign_type");
        try {
            buyer_pay_amount = Double.parseDouble(params.get("buyer_pay_amount"));
        } catch (Exception e) {
        }
        sign = params.get("sign");
        try {
            point_amount = Double.parseDouble(params.get("point_amount"));
        } catch (Exception e) {
        }
        try {
            fund_bill_list = new BeanUtil3().jsonToList(params.get("fund_bill_list"), FundBill.class);
        } catch (Exception e) {
        }
    }

    public void setFund_bill_list(List<FundBill> fund_bill_list) {
        this.fund_bill_list = fund_bill_list;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public void setTrade_no(String trade_no) {
        this.trade_no = trade_no;
    }

    public void setGmt_create(String gmt_create) {
        this.gmt_create = gmt_create;
    }

    public void setNotify_type(String notify_type) {
        this.notify_type = notify_type;
    }

    public void setTotal_amount(Double total_amount) {
        this.total_amount = total_amount;
    }

    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }

    public void setInvoice_amount(Double invoice_amount) {
        this.invoice_amount = invoice_amount;
    }

    public void setOpen_id(String open_id) {
        this.open_id = open_id;
    }

    public void setSeller_id(String seller_id) {
        this.seller_id = seller_id;
    }

    public void setNotify_time(String notify_time) {
        this.notify_time = notify_time;
    }

    public void setTrade_status(String trade_status) {
        this.trade_status = trade_status;
    }

    public void setGmt_payment(String gmt_payment) {
        this.gmt_payment = gmt_payment;
    }

    public void setSeller_email(String seller_email) {
        this.seller_email = seller_email;
    }

    public void setReceipt_amount(Double receipt_amount) {
        this.receipt_amount = receipt_amount;
    }

    public void setBuyer_id(String buyer_id) {
        this.buyer_id = buyer_id;
    }

    public void setApp_id(String app_id) {
        this.app_id = app_id;
    }

    public void setNotify_id(String notify_id) {
        this.notify_id = notify_id;
    }

    public void setBuyer_logon_id(String buyer_logon_id) {
        this.buyer_logon_id = buyer_logon_id;
    }

    public void setSign_type(String sign_type) {
        this.sign_type = sign_type;
    }

    public void setBuyer_pay_amount(Double buyer_pay_amount) {
        this.buyer_pay_amount = buyer_pay_amount;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public void setPoint_amount(Double point_amount) {
        this.point_amount = point_amount;
    }

    public static void main(String[] args) throws Exception {
        Map<String, String> params = HttpUtil.paramsToMap(a, "utf8");
        System.out.println(new BeanUtil3().beanToJson(new ZfbCallback(params)));
    }

    static String a = "total_amount=1.00&buyer_id=2088202272379392&trade_no=2017033121001004390230940718&notify_time=2017-03-31+19%3A14%3A37&open_id=20881034403024658252872930714739&subject=%E8%B4%A6%E5%8F%B7%EF%BC%9Aadmin%E5%85%85%E5%80%BC%5B1.0%5D%E5%85%83&sign_type=RSA&buyer_logon_id=yan***%40gmail.com&auth_app_id=2016120203720547&charset=utf-8&notify_type=trade_status_sync&out_trade_no=41499d2ceb4f4dce830eb98173600a693589c9b80703401e857384624af1621d&trade_status=WAIT_BUYER_PAY&version=1.0&sign=poY9hKCmNNBzkWBSVWzOMNxrc899Re7oLOY%2FDdZfrcGkeUBPSeAhTX964ks%2BCSxXKttaVVo24kiZSGBlrNoqL1qAt5ntYGAfJGSGIHjl8cSzRC9lICEMirK5%2FgMjWA1zwIsFBOECUdPSiRWXdERCTuPXnc%2F2bRzsLblwNURjuwQ%3D&gmt_create=2017-03-31+19%3A14%3A37&app_id=2016120203720547&seller_id=2088812895658475&notify_id=1d3d79b0ce1a91cb10b15073cddc7d5j0e&seller_email=13601117948%40139.com";
    static String b = "buyer_id=2088202272379392&total_amount=1.00&trade_no=2017033121001004390230948041&notify_time=2017-03-31+19%3A20%3A28&open_id=20881034403024658252872930714739&subject=%E8%B4%A6%E5%8F%B7%EF%BC%9Aadmin%E5%85%85%E5%80%BC%5B1.0%5D%E5%85%83&sign_type=RSA&buyer_logon_id=yan***%40gmail.com&auth_app_id=2016120203720547&charset=utf-8&notify_type=trade_status_sync&invoice_amount=1.00&out_trade_no=27b9ae85df7d4eabb35494188dd54bc6a9193ee286d04352bad77e1887e6567e&trade_status=TRADE_SUCCESS&gmt_payment=2017-03-31+19%3A20%3A28&version=1.0&point_amount=0.00&sign=UmXs0Bmq2aSpqh768s03uQLiFEBkCd47CBSLkQ4brJvI%2BSxU2j9P34TckUSXJTa8SUQryuxWKWPiJiER%2BUfLtJV91cE1Nvsz6EkzjRXPRDdzQ3TtdRUwkxWM4f4zdNhTowuj39UodH36%2FGjefI2F5Gh%2Bd4lSK4%2Bjv%2FD6eOQtnrQ%3D&gmt_create=2017-03-31+19%3A20%3A21&buyer_pay_amount=1.00&receipt_amount=1.00&fund_bill_list=%5B%7B%22amount%22%3A%221.00%22%2C%22fundChannel%22%3A%22PCREDIT%22%7D%5D&app_id=2016120203720547&seller_id=2088812895658475&notify_id=01223f9935284ac9c5fe70c4615bc2bj0e&seller_email=13601117948%40139.com";
}
